<?php
include('connection.php');
include('thuvien.php');
class SanPham
{
var $MaSP;
var $TenSP;
var $HinhAnh;
var $Gia;
var $MoTa;
var $MaNSX;
public function InfoSanPham($MaSP,$TenSP,$HinhAnh,$Gia,$MoTa,$MaNSX)
{
$this->MaSP=$MaSP;
$this->TenSP=$TenSP;
$this->HinhAnh=$HinhAnh;
$this->Gia=$Gia;
$this->MoTa=$MoTa;
$this->MaNSX=$MaNSX;
}
public function GetAll_SanPham()
{
$sql ="Select * From San_Pham";
$kq=@mysql_query($sql) or die (@mysql_error());
return $kq;
}
public function Add_SanPham($TenSP,$HinhAnh,$Gia,$MoTa,$MaNSX)
{
$sql ="INSERT INTO `san_pham` (`TenSP`, `HinhAnh`, `Gia`, `MoTa`, `MaNSX`) VALUES ('$TenSP','$HinhAnh','$Gia','$MoTa','$MaNSX')";
$kq=@mysql_query($sql) or die (@mysql_error());
}
public function Update_SanPham($MaSP,$TenSP,$HinhAnh,$Gia,$MoTa,$MaNSX)
{
$sql ="Update San_Pham Set `TenSP`='$TenSP',`HinhAnh`='$HinhAnh',`Gia`='$Gia',`MoTa`='$MoTa',`MaNSX`='$MaNSX' Where MaSP=$MaSP";
$kq=@mysql_query($sql) or die (@mysql_error());
return $kq;
}
public function Delete_SanPham($MaSP)
{
$sql="Delete From San_Pham Where MaSP=$MaSP"; 
$kq=@mysql_query($sql) or die (@mysql_error());
return $kq;
}
public function GetbyID($id)
{
$sql="Select * from San_Pham Where MaSP=$id";
$kq=@mysql_query($sql) or die (@mysql_error());
return $kq;
}
var $pindex;
var $totalp;

public function get_by_page($psize, $pindex, $where = '', $orderby = '')
{
	$this->pindex = $pindex;
	return get_page($psize, $pindex, $this->totalp, 'San_Pham', $where = "",$orderby = "");
}
public function print_page()
{
	return print_page($this->totalp, $this->pindex);
}
}
?>